package com.ssl.mall.coupon.controller;


import com.ssl.mall.coupon.entity.Coupon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import com.ssl.mall.common.bean.Result;
import com.ssl.mall.coupon.service.ICouponService;

import java.util.Arrays;

/**
 * <p>
 * 优惠券信息 前端控制器
 * </p>
 *
 * @author ssl
 * @since 2021-04-25
 */
@RefreshScope
@RestController
@RequestMapping("/coupon/coupon")
public class CouponController {

	@Autowired
	private ICouponService couponService;

	@Value("${coupon.test.name}")
	private String testName;

	@GetMapping("test")
	public Result test(){
		return Result.ok().put("name", testName);
	}

	@GetMapping("member/list")
	public Result memberCoupons() {
		Coupon coupon = new Coupon();
		coupon.setCouponName("满100减10");

		return Result.ok().put("coupons", Arrays.asList(coupon));
	}
	
	@GetMapping("list")
	public Result list() {
		return Result.ok().put("data", couponService.list());
	}
}

